g_refresh_delay = 30000;

g_colorname = ["", "red", "blue", "green"];
g_numcolor = [0,1,1,2,2,3,3,1,1,2,2,3,1,1,2,2,3,3,1,1,2,3,3,1,1,2,2,3,3,1,1,2,3,3,1,1,2,2,3,3,1,2,2,3,3,1,1,2,2,3];

var _orderid = 1;
var M = new Object();
M.charset = "big5";
M.Rates = new Array();
M.Rates[0] = new Array();  // 特码A、正码A
for (i=0; i<49; i++) { M.Rates[0][i+1] = 0; }
M.Rates[24] = new Array();  // 特码B、正码B
for (i=0; i<49; i++) { M.Rates[24][i+1] = 0; }
M.Rates[10] = new Array();  //正码特A
for (i=0; i<49; i++) { M.Rates[10][i+1] = 0; }
M.Rates[11] = new Array();  //正码特B
for (i=0; i<49; i++) { M.Rates[11][i+1] = 0; }
M.Rates[1] = [0,0]; // 特单双
M.Rates[2] = [0,0]; // 特大小
M.Rates[3] = [0,0]; // 合单双
M.Rates[4] = [0,0]; // ------------->?用到
M.Rates[5] = [0,0]; // 总单双
M.Rates[6] = [0,0]; // 总大小
M.Rates[13] = [0,0,0]; // 色波
M.Rates[14] = [0,0,0,0,0,0,0,0,0,0,0,0]; // 生肖
M.Rates[18] = [0,0,0,0,0,0,0,0,0,0,0,0]; // 半波
M.Rates[20] = [0,0]; // 家禽野兽
M.Rates[21] = [0,0,0,0,0,0,0,0,0,0,0,0]; // 一肖A
M.Rates[22] = [0,0,0,0,0,0,0,0,0,0]; // 尾数A
M.Rates[37] = [0,0,0,0,0,0,0,0,0,0,0,0]; // 一肖B
M.Rates[38] = [0,0,0,0,0,0,0,0,0,0]; // 尾数B
M.Rates[28] = [0,0];    // 特尾大小
M.Rates[30] = [0,0];    // 合尾大小
M.Rates[34] = [0,0,0,0];// 总肖
M.Rates[35] = [0,0];    // 总肖单双    
M.Rates[46] = [0,0,0];  // 特大中小
M.Rates[47] = [0,0];    // 合大小

M.Rates[36] = new Array();  // 正码 1-6
for (i=0; i<54; i++) { M.Rates[36][i+1] = 0; }
if(window.ActiveXObject)
{
	var xh =  new ActiveXObject("Microsoft.XMLHTTP");
}else{
	var xh =  new XMLHttpRequest();
}

// 检查表格号码
function CheckNumber(itype)
{
	if (parseInt(event.srcElement.value) < 1 || parseInt(event.srcElement.value) > 49) {
		alert("第"+itype+"组号码输入错误（1～49）");
		event.srcElement.value = "";
		event.srcElement.focus();
		return false;
	}
}

// 产生表格 iType = 0 or 1
function GetBet0(iType)
{
	s = "<table cellSpacing=1 cellPadding=1 border=0 width=640>";
	s += "<tr height=27 bgColor=#5a79c6 align=center style=\"color:#ffffff\">";
	for (var i=0; i<5; i++) {
		if (iType==3 || iType==4)
			s=="<td nowrap>号码</td><td nowrap>赔率</td>";
		else
			if (iType==11)
				s+="<td nowrap class=c3>号码</td><td nowrap class=c3>赔率</td><td class=c3>选择</td>";
			else
				s+="<td nowrap>号码</td><td nowrap>赔率</td><td>选择</td>";
	}
	for (var i=1; i<=10; i++) {
		s+="<tr bgColor=#e7ebef align=center height=27>";
		s+=GetBet0Item(iType, i);
		s+=GetBet0Item(iType, i+10);
		s+=GetBet0Item(iType, i+20);
		s+=GetBet0Item(iType, i+30);
		if ((i+40) < 50)
			s+=GetBet0Item(iType, i+40);
		else if (iType==0 || iType==8)
			if (iType==11)
				s+="<td class=c5 colspan=3><span style='#000000;font-size:11pt;font-weight:bold;'>金额</span> <input name=r0m size=4 maxlength=7 onkeypress=\"return KeyNumber()\"></td>";
			else
				if (iType==10)
					s+="<td colspan=3><span style='#000000;font-size:11pt;font-weight:bold;'>金额</span> <input name=r0m size=4 maxlength=7 onkeypress=\"return KeyNumber()\"></td>";
				else
					s+="<td colspan=3><span style='#000000;font-size:11pt;font-weight:bold;'>金额</span> <input name=r0m size=4 maxlength=7 onkeypress=\"return KeyNumber()\"></td>";
		else
			s+="<td></td>";
	}
	s += "</table>";
	return s;
}

// 产生表格 iType = 0 or 1 or 2 or 3
function GetBet024(iType)
{
	s = "<table cellSpacing=1 cellPadding=1 border=0 width=640>";
	s += "<tr height=27 bgColor=#5a79c6 align=center style=\"color:#ffffff\">";
	for (var i=0; i<5; i++) {
		s+="<td nowrap class=c3>号码</td><td nowrap class=c3>赔率</td><td class=c3>选择</td>";
	}
	for (var i=1; i<=10; i++) {
		s+="<tr bgColor=#e7ebef align=center height=27>";
		s+=GetBet024Item(iType, i);
		s+=GetBet024Item(iType, i+10);
		s+=GetBet024Item(iType, i+20);
		s+=GetBet024Item(iType, i+30);
		if ((i+40) < 50)
			s+=GetBet024Item(iType, i+40);
		else if (iType==0 || iType==2)
			s+="<td class=c5 colspan=3><span style='#000000;font-size:11pt;font-weight:bold;'>金额</span> <input name=r0m size=4 maxlength=7 onkeypress=\"return KeyNumber()\"></td>";
		else
			s+="<td></td>";
	}
	s += "</table>";
	return s;
}

function ShowBet0()
{
	window.status = "更新赔率中......";
	var s = GetBet(0);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
			document.all.idBetOther.style.display = "none";
		}
	} else {
		document.all.idBetOther.style.display = "";
		// 特码A  proc1
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 0, i, ary[i], "proc1", d2(i));
		}
		// 特单双  proc2
		ParseRateLink(rr1_1, 1, 0, ary[50], "proc2", 1);
		ParseRateLink(rr1_2, 1, 1, ary[51], "proc2", 2);
		// 特大小  proc3
		ParseRateLink(rr2_1, 2, 0, ary[52], "proc3", 1);
		ParseRateLink(rr2_2, 2, 1, ary[53], "proc3", 2);
		// 合单双  proc4
		ParseRateLink(rr3_1, 3, 0, ary[54], "proc4", 1);
		ParseRateLink(rr3_2, 3, 1, ary[55], "proc4", 2);
		// 总单双  proc6
		ParseRateLink(rr5_1, 5, 0, ary[56], "proc6", 1);
		ParseRateLink(rr5_2, 5, 1, ary[57], "proc6", 2);
		// 总大小  proc7
		ParseRateLink(rr6_1, 6, 0, ary[58], "proc7", 1);
		ParseRateLink(rr6_2, 6, 1, ary[59], "proc7", 2);
		// 色波  proc10
		ParseRateLink(rr13_1, 13, 0, ary[60], "proc10", 1);
		ParseRateLink(rr13_2, 13, 1, ary[61], "proc10", 2);
		ParseRateLink(rr13_3, 13, 2, ary[62], "proc10", 3);
		// 生肖  proc9
		for (i=0; i<12; i++) {
			ParseRateLink(eval("rr14_"+(i+1)), 14, i, ary[63+i], "proc9", i+1);
		}
		// 禽兽  proc15
		ParseRateLink(rr20_1, 20, 0, ary[75], "proc15", 1);
		ParseRateLink(rr20_2, 20, 1, ary[76], "proc15", 2);
		// 特尾大小  proc28
		ParseRateLink(rr28_1, 28, 0, ary[77], "proc28", 1);
		ParseRateLink(rr28_2, 28, 1, ary[78], "proc28", 2);
		// 合尾大小  proc30
		ParseRateLink(rr30_1, 30, 0, ary[79], "proc30", 1);
		ParseRateLink(rr30_2, 30, 1, ary[80], "proc30", 2);
		// 特大中小  proc46
		ParseRateLink(rr46_1, 46, 0, ary[81], "proc46", 1);
		ParseRateLink(rr46_2, 46, 1, ary[82], "proc46", 2);
		ParseRateLink(rr46_3, 46, 2, ary[83], "proc46", 3);
		// 合大小  proc47
		ParseRateLink(rr47_1, 47, 0, ary[84], "proc47", 1);
		ParseRateLink(rr47_2, 47, 1, ary[85], "proc47", 2);
	}
	window.status = "";
	setTimeout("ShowBet0()", g_refresh_delay);
}

function ShowBet024()
{
	window.status = "更新赔率中......";
	var s = GetBet(9);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
			document.all.idBetOther.style.display = "none";
		}
	} else {
		document.all.idBetOther.style.display = "";

		// 特码B  proc124
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 24, i, ary[i], "proc124", d2(i));
		}
		// 特单双  proc2
		ParseRateLink(rr1_1, 1, 0, ary[50], "proc2", 1);
		ParseRateLink(rr1_2, 1, 1, ary[51], "proc2", 2);
		// 特大小  proc3
		ParseRateLink(rr2_1, 2, 0, ary[52], "proc3", 1);
		ParseRateLink(rr2_2, 2, 1, ary[53], "proc3", 2);
		// 合单双  proc4
		ParseRateLink(rr3_1, 3, 0, ary[54], "proc4", 1);
		ParseRateLink(rr3_2, 3, 1, ary[55], "proc4", 2);
		// 总单双  proc6
		ParseRateLink(rr5_1, 5, 0, ary[56], "proc6", 1);
		ParseRateLink(rr5_2, 5, 1, ary[57], "proc6", 2);
		// 总大小  proc7
		ParseRateLink(rr6_1, 6, 0, ary[58], "proc7", 1);
		ParseRateLink(rr6_2, 6, 1, ary[59], "proc7", 2);
		// 色波  proc10
		ParseRateLink(rr13_1, 13, 0, ary[60], "proc10", 1);
		ParseRateLink(rr13_2, 13, 1, ary[61], "proc10", 2);
		ParseRateLink(rr13_3, 13, 2, ary[62], "proc10", 3);
		// 生肖  proc9
		for (i=0; i<12; i++) {
			ParseRateLink(eval("rr14_"+(i+1)), 14, i, ary[63+i], "proc9", i+1);
		}
		// 禽兽  proc15
		ParseRateLink(rr20_1, 20, 0, ary[75], "proc15", 1);
		ParseRateLink(rr20_2, 20, 1, ary[76], "proc15", 2);
		// 特尾大小  proc28
		ParseRateLink(rr28_1, 28, 0, ary[77], "proc28", 1);
		ParseRateLink(rr28_2, 28, 1, ary[78], "proc28", 2);
		// 合尾大小  proc30
		ParseRateLink(rr30_1, 30, 0, ary[79], "proc30", 1);
		ParseRateLink(rr30_2, 30, 1, ary[80], "proc30", 2);
		// 特大中小  proc46
		ParseRateLink(rr46_1, 46, 0, ary[81], "proc46", 1);
		ParseRateLink(rr46_2, 46, 1, ary[82], "proc46", 2);
		ParseRateLink(rr46_3, 46, 2, ary[83], "proc46", 3);
		// 合大小  proc47
		ParseRateLink(rr47_1, 47, 0, ary[84], "proc47", 1);
		ParseRateLink(rr47_2, 47, 1, ary[85], "proc47", 2);
	}
	window.status = "";
	setTimeout("ShowBet024()", g_refresh_delay);
}

function ShowBet0b()
{
	window.status = "更新赔率中......";
	var s = GetBet(0);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		// 特码A  proc1
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 0, i, ary[i], "proc1", d2(i));
		}
	}
	window.status = "";
	setTimeout("ShowBet0b()", g_refresh_delay);
}

function ShowBet024b()
{
	window.status = "更新赔率中......";
	var s = GetBet(9);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		// 特码A  proc1
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 24, i, ary[i], "proc124", d2(i));
		}
	}
	window.status = "";
	setTimeout("ShowBet024b()", g_refresh_delay);
}

function ShowBet6()
{
	window.status = "更新赔率中......";
	var s = GetBet(6);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
			document.all.idBetOther.style.display = "none";
		}
	} else {
		document.all.idBetOther.style.display = "";
		// 特单双proc2
		ParseRateLink(rr1_1, 1, 0, ary[1], "proc2", 1);
		ParseRateLink(rr1_2, 1, 1, ary[2], "proc2", 2);
		// 特大小proc3
		ParseRateLink(rr2_1, 2, 0, ary[3], "proc3", 1);
		ParseRateLink(rr2_2, 2, 1, ary[4], "proc3", 2);
		// 合单双proc4
		ParseRateLink(rr3_1, 3, 0, ary[5], "proc4", 1);
		ParseRateLink(rr3_2, 3, 1, ary[6], "proc4", 2);
		// 总单双proc6
		ParseRateLink(rr5_1, 5, 0, ary[7], "proc6", 1);
		ParseRateLink(rr5_2, 5, 1, ary[8], "proc6", 2);
		// 总大小proc7
		ParseRateLink(rr6_1, 6, 0, ary[9], "proc7", 1);
		ParseRateLink(rr6_2, 6, 1, ary[10], "proc7", 2);
		// 色波proc10
		ParseRateLink(rr13_1, 13, 0, ary[11], "proc10", 1);
		ParseRateLink(rr13_2, 13, 1, ary[12], "proc10", 2);
		ParseRateLink(rr13_3, 13, 2, ary[13], "proc10", 3);
		// 生肖 proc9
		for (i=0; i<12; i++) {
			ParseRateLink(eval("rr14_"+(i+1)), 14, i, ary[14+i], "proc9", i+1);
		}
		// 禽兽  proc15
		ParseRateLink(rr20_1, 20, 0, ary[26], "proc15", 1);
		ParseRateLink(rr20_2, 20, 1, ary[27], "proc15", 2);
		// 特尾大小  proc28
		ParseRateLink(rr28_1, 28, 0, ary[28], "proc28", 1);
		ParseRateLink(rr28_2, 28, 1, ary[29], "proc28", 2);
		// 合尾大小  proc30
		ParseRateLink(rr30_1, 30, 0, ary[30], "proc30", 1);
		ParseRateLink(rr30_2, 30, 1, ary[31], "proc30", 2);
		// 特大中小  proc46
		ParseRateLink(rr46_1, 46, 0, ary[32], "proc46", 1);
		ParseRateLink(rr46_2, 46, 1, ary[33], "proc46", 2);
		ParseRateLink(rr46_3, 46, 2, ary[34], "proc46", 3);
		// 合大小  proc47
		ParseRateLink(rr47_1, 47, 0, ary[35], "proc47", 1);
		ParseRateLink(rr47_2, 47, 1, ary[36], "proc47", 2);
	}
	window.status = "";
	setTimeout("ShowBet6()", g_refresh_delay);
}

function ShowBet1()
{
	window.status = "更新赔率中......";
	var s = GetBet(1);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
			document.all.idBetOther.style.display = "none";
		}
	} else {
		document.all.idBetOther.style.display = "";
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 0, i, ary[i], "proc1", d2(i));
		}
		// 特单双
		ParseRateLink(rr1_1, 1, 0, ary[50], "proc2", 1);
		ParseRateLink(rr1_2, 1, 1, ary[51], "proc2", 2);
		// 特大小
		ParseRateLink(rr2_1, 2, 0, ary[52], "proc3", 1);
		ParseRateLink(rr2_2, 2, 1, ary[53], "proc3", 2);
		// 合单双
		ParseRateLink(rr3_1, 3, 0, ary[54], "proc4", 1);
		ParseRateLink(rr3_2, 3, 1, ary[55], "proc4", 2);
		// 禽兽  proc15
		ParseRateLink(rr20_1, 20, 0, ary[56], "proc15", 1);
		ParseRateLink(rr20_2, 20, 1, ary[57], "proc15", 2);
		// 特尾大小  proc28
		ParseRateLink(rr28_1, 28, 0, ary[58], "proc28", 1);
		ParseRateLink(rr28_2, 28, 1, ary[59], "proc28", 2);
		// 合尾大小  proc30
		ParseRateLink(rr30_1, 30, 0, ary[60], "proc30", 1);
		ParseRateLink(rr30_2, 30, 1, ary[61], "proc30", 2);
		// 合大小  proc47
		ParseRateLink(rr47_1, 47, 0, ary[62], "proc47", 1);
		ParseRateLink(rr47_2, 47, 1, ary[63], "proc47", 2);
	}
	window.status = "";
	setTimeout("ShowBet1()", g_refresh_delay);
}

function ShowBet2()	 // 正码A快速
{
	window.status = "更新赔率中......";
	var s = GetBet(2);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 0, i, ary[i], "proc5", d2(i));
		}
		// 总单双
		ParseRateLink(rr5_1, 5, 0, ary[50], "proc6", 1);
		ParseRateLink(rr5_2, 5, 1, ary[51], "proc6", 2);
		// 总大小
		ParseRateLink(rr6_1, 6, 0, ary[52], "proc7", 1);
		ParseRateLink(rr6_2, 6, 1, ary[53], "proc7", 2);
	}
	window.status = "";
	setTimeout("ShowBet2()", g_refresh_delay);
}

function ShowBet2b()	// 正码B快速
{
	window.status = "更新赔率中......";
	var s = GetBet(12);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 0, i, ary[i], "proc50", d2(i));
		}
		// 总单双
		ParseRateLink(rr5_1, 5, 0, ary[50], "proc6", 1);
		ParseRateLink(rr5_2, 5, 1, ary[51], "proc6", 2);
		// 总大小
		ParseRateLink(rr6_1, 6, 0, ary[52], "proc7", 1);
		ParseRateLink(rr6_2, 6, 1, ary[53], "proc7", 2);
	}
	window.status = "";
	setTimeout("ShowBet2b()", g_refresh_delay);
}

function ShowBet2t(iMod)
{
	window.status = "更新赔率中......";
	var s = GetBet(10 + iMod);
	if (s=="") {
		window.status = "";
		return;
	}
	var procname = "proc5a";
	if (iMod == 1) {
		procname = "proc5b";
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 10+iMod, i, ary[i], procname, d2(i));
		}
	}
	window.status = "";
	setTimeout("ShowBet2t("+iMod+")", g_refresh_delay);
}

function ShowBet8()	// 正码A勾选
{
	window.status = "更新赔率中......";
	var s = GetBet(8);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 0, i, ary[i], "proc5", d2(i));
		}
	}
	window.status = "";
	setTimeout("ShowBet8()", g_refresh_delay);
}

function ShowBet8b()	// 正码B勾选
{
	window.status = "更新赔率中......";
	var s = GetBet(13);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		for (var i=1; i<=49; i++) {
			ParseRateLink(eval("rr0_"+i), 0, i, ary[i], "proc50", d2(i));
		}
	}
	window.status = "";
	setTimeout("ShowBet8b()", g_refresh_delay);
}


// 正码 1 - 6
function ShowBet3()
{
	var i, j, k;
	window.status = "更新赔率中......";
	var s = GetBet(3);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		k = 1;   
		for (i=1; i<=6; i++) {
		    for (j=1; j<=9; j++) {
		    	ParseRateLink(eval("rr15_"+i+"_"+j), 36, k, ary[k], "proc8", i+"&type="+j);
		    	k++;
		    }
		}
	}
	window.status = "";
	setTimeout("ShowBet3()", g_refresh_delay);
}

// 生肖色波
function ShowBet4()
{
	window.status = "更新赔率中......";
	var s = GetBet(4);
	if (s=="") {
		window.status = "";
		return;
	}
	
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		// 色波
		ParseRateLink(rr13_1, 13, 0, ary[1], "proc10", 1);
		ParseRateLink(rr13_2, 13, 1, ary[2], "proc10", 2);
		ParseRateLink(rr13_3, 13, 2, ary[3], "proc10", 3);
		// 生肖
		for (i=0; i<12; i++) {
			ParseRateLink(eval("rr14_"+(i+1)), 14, i, ary[4+i], "proc9", i+1);
		}
	}
	window.status = "";
	setTimeout("ShowBet4()", g_refresh_delay);
}

// 半波
function ShowBet5()
{
	window.status = "更新赔率中......";
	var s = GetBet(5);
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		} else {
			s = "<p class=error>"+ary[1]+"</p>";
			document.all.idBet0.innerHTML = s;
		}
	} else {
		for (i=0; i<12; i++) {
			ParseRateLink(eval("rr18_"+(i+1)), 18, i, ary[1+i], "proc13", i+1);
		}
	}
	window.status = "";
	setTimeout("ShowBet5()", g_refresh_delay);
}

// 生肖尾数
function ShowBet7(bets_id)
{
	window.status = "更新赔率中......";
	var s = GetBet(((bets_id==1) ? "7" : "14" ));
	if (s=="") {
		window.status = "";
		return;
	}
	var ary = s.split(",");
	if (ary[0]!="1") {
		if (ary[0]=="6") {
			parent.leftFrame.location.href='op.php?op=member&fp=account';
			location.reload();
		}
	} else {
		j = 1;
		for (i=0; i<12; i++) {
		  if (bets_id=="1")
			   ParseRateLink(eval("rr21_"+(i+1)), 21, i, ary[j], "proc16&btype=21", i+1);
			else
			   ParseRateLink(eval("rr21_"+(i+1)), 37, i, ary[j], "proc16&btype=37", i+1);
			j++;
		}
		for (i=0; i<10; i++) {
		  if (bets_id=="1")
			   ParseRateLink(eval("rr22_"+(i+1)), 22, i, ary[j], "proc17&btype=22", i+1);
			else
			   ParseRateLink(eval("rr22_"+(i+1)), 38, i, ary[j], "proc17&btype=38", i+1);
			j++;
		}
		// 总肖
		ParseRateLink(rr34_4, 34, 0, ary[j], "proc34", 4);
		ParseRateLink(rr34_5, 34, 1, ary[j+1], "proc34", 5);
		ParseRateLink(rr34_6, 34, 2, ary[j+2], "proc34", 6);
		ParseRateLink(rr34_7, 34, 3, ary[j+3], "proc34", 7);
		// 总肖单双
		ParseRateLink(rr35_1, 35, 0, ary[j+4], "proc35", 1);
		ParseRateLink(rr35_2, 35, 1, ary[j+5], "proc35", 2);
	}
	window.status = "";
	setTimeout("ShowBet7("+bets_id+")", g_refresh_delay);
}

function GetBetLink(sProc, sNum, sRate)
{
  var disk = document.getElementById("select_disk").value;
	return "<a href=\"op.php?op=member&fp="+sProc+"&num="+sNum+"&rate="+sRate+"&ord="+_orderid+"&disk="+disk
		+"\" target=leftFrame class=betnum><span style='color:#ff0000;font-size:11pt;font-weight:bold;'>"
		+sRate+"</span></a>";
}

function ParseRateLink(obj, m1, m2, rate, sProc, sNume)
{
	var sLink = GetBetLink(sProc, sNume, rate);     
	obj.innerHTML = sLink;
	//if (M.Rates[m1][m2]==0) {
	//	obj.innerHTML = sLink;
	//} else 
  if (M.Rates[m1][m2]!=rate) {
		obj.className = "rc";
		obj.innerHTML = sLink;
	} else {
		if (sProc=="proc13") {
			obj.className = "c1";
		} else {
			obj.className = "c2";
		}
	}
	M.Rates[m1][m2] = rate;
}


function GetBet0Item(iType, i)
{
	var sProc = "proc1";
	if (iType==4 || iType==8) sProc = "proc5"; // 正码A
	if (iType==10) sProc = "proc5a"; // 正码特a
	if (iType==11) sProc = "proc5b"; // 正码特b
	var ii = d2(i);
	var s1 = "<td class=c2 nowrap><img width='26' heigth='26' src=image/ball_S"+ii+".gif></td>"
		+"<td class=c6 nowrap id=rr0_"+i+">"+GetBetLink(sProc, ii, 0)+"</td>";
	if (iType==0 || iType==8)
		s1+="<td class=c1 nowrap><input type=checkbox name=\"r0[]\" value="+ii+" id=rrr0_"+ii+"></td>";
	else if (iType==1 || iType==9 || iType==10 || iType==11)
		s1+="<td class=c2 nowrap><input name=r0_"+ii+" size=3 maxlength=7 onchange=\"totalBetAmount()\" onkeypress=\"return KeyNumber()\" tabIndex="+i+"></td>";
	return s1;
}
					
function GetBet024Item(iType, i)
{
	var sProc = "proc124";
	if (iType==2 || iType==3) sProc = "proc50"; // 正码B
	var ii = d2(i);
	var s1 = "<td class=c2 nowrap><img width='26' heigth='26' src=image/ball_S"+ii+".gif></td>"
		+"<td class=c6 nowrap id=rr0_"+i+">"+GetBetLink(sProc, ii, 0)+"</td>";
	if (iType==0 || iType==2)
		s1+="<td class=c1 nowrap><input type=checkbox name=\"r0[]\" value="+ii+" id=rrr0_"+ii+"></td>";
	else if (iType==1 || iType==3)
		s1+="<td class=c2 nowrap><input name=r0_"+ii+" size=3 maxlength=7 onchange=\"totalBetAmount()\" onkeypress=\"return KeyNumber()\" tabIndex="+i+"></td>";
	return s1;
}


function GetBet(t)
{
	var disk = document.getElementById("select_disk").value;
  	xh.open("POST", "xml.php?b="+t+"-"+_orderid+"&disk="+disk,false);
	xh.setRequestHeader("Content-Type","text/xml;charset="+M.Charset);
	try {
		xh.send("");
		return (xh.responseText);
	} catch (e) {
		alert(e);
		return "";
	}
}

function GetBet3()
{
	var i, j;
	var name1 = ["单","双","大","小","红波","蓝波","绿波","合单","合双"];
	var str = "<table border=0 width=640 cellspacing=2 cellpadding=2><tr>"
		+"<td colspan=2 class=c0>正码一</td>"
		+"<td colspan=2 class=c0>正码二</td>"
		+"<td colspan=2 class=c0>正码三</td>"
		+"<td colspan=2 class=c0>正码四</td>"
		+"<td colspan=2 class=c0>正码五</td>"
		+"<td colspan=2 class=c0>正码六</td></tr><tr>";
	for (i=0; i<6; i++) {
		str += "<td class=c1>项目</td><td class=c2>赔率</td>";
	}
	str += "</tr>";
	for (i=0; i<9; i++) {
		str+="<tr align=center>";
		for (j=0; j<6; j++) {
			if (i==4) {
				str+="<td class=c1><span style='color:#ef0000;font-size:11pt;font-weight:bold;'>"+name1[i]+"</span></td>";
			} else if (i==5) {
				str+="<td class=c1><span style='color:#0000ef;font-size:11pt;font-weight:bold;'>"+name1[i]+"</span></td>";
			} else if (i==6) {
				str+="<td class=c1><span style='color:#006a00;font-size:11pt;font-weight:bold;'>"+name1[i]+"</span></td>";
			} else {
				str+="<td class=c1><span style='color:#000000;font-size:11pt;font-weight:bold;'>"+name1[i]+"</span></td>";
			}
			str+="<td class=c6 id=rr15_"+(j+1)+"_"+(i+1)+">"+GetBetLink("proc8", (j+1)+"&type="+(i+1), 0)+"</td>";
		}
		str+="</tr>";
	}
	str+="</table>";
	return str;
}

function nowdate()
{
    document.all.hktime.innerHTML = "现在 <b>"+now.getDate()+"</b> 日 <b>"+d2(now.getHours())+" : "+d2(now.getMinutes())+" : "+d2(now.getSeconds())+"</b>";
    now.setTime(now.getTime() + 1000);
    setTimeout("nowdate()",1000);
}
function d2(v)
{
	return (v<=9?'0':'')+v;	
}
function countdown()
{
  timediff = timestap;
  days = Math.floor(timediff / (60 * 60 * 24));
	timediff -= days * (60 * 60 * 24);
	hours = Math.floor(timediff / (60 * 60));
	timediff -= hours * (60 * 60);
	mins = Math.floor(timediff / (60));
	timediff -= mins * (60);
	secs = Math.floor(timediff);

    str = "离截止下注 ";
    if (days > 0 ) str += "<b>" + days + "</b> 天 ";
    if (hours > 0) str += "<b>" + hours + "</b> 时 ";  // 
    if (mins > 0) str += "<b>" + d2(mins) + "</b> 分 ";  // 
    str += "<b>" + d2(secs) + "</b> 秒"; //
    countdownstr.innerHTML =  str;
    setTimeout("countdown()",1000)
    timestap-=1;
    if (timestap==0) {
        location.reload();
    }
}

/* 取得生肖年的配置,
/* 则传回依生肖对应号码组合的阵列
/* index =1~12 , TwelveAnimalSeed=生肖本命年(k_config->get("chinayear"))
*/
function GetChinaYearNumber(index , TwelveAnimalSeed){
    if (index<=0 || index>12) return NaN;

		var tmpTwelveAnimalArray = [null,
		[1,13,25,37,49],   //1
		[2,14,26,38],      //2
		[3,15,27,39],      //3
		[4,16,28,40],      //4
		[5,17,29,41],      //5
		[6,18,30,42],      //6
		[7,19,31,43],      //7
		[8,20,32,44],      //8
		[9,21,33,45],      //9
		[10,22,34,46],     //10
		[11,23,35,47],     //11
		[12,24,36,48]];    //12

    var mapingArray = new Array();//用来存放对应的阵列
    for(var i=1;i <= 12;i++){
        if(i == TwelveAnimalSeed){//等於种子者为1
            mapingArray[i] = 1;
        }else if(i < TwelveAnimalSeed){//小於种子的
            mapingArray[i] = (TwelveAnimalSeed - i)+1;
        }else{//大於种子的
            var tmpLoopNum = i-TwelveAnimalSeed;
            var tmpCunt = 0;
            for(var j=12;j >=1 ;j--){
                tmpCunt++;
                if(tmpCunt == tmpLoopNum){
                    mapingArray[i] = j;
                    break;
                }
            }
        }
    }
    return tmpTwelveAnimalArray[mapingArray[index]];
}
/***
 *计算特码,正码选取下注项目的合计
 */ 
function totalBetAmount(){
  var nums=0,totalAmt=0;
  for (var i=1; i<50; i++) {
    var fieldValue = document.all["r0_"+d2(i)].value;
  	if (fieldValue != "*" && (fieldValue-0)>0) {
  		totalAmt += fieldValue-0;
  		nums++;
  	}
  }
  var message="";
  if (nums>0) message = totalAmt + " (共"+ nums +"号)";
  document.getElementById("betStatus").innerHTML = message;
}
